import * as React from "react";
import SearchAndFilter from "../../component/SearchAndFilter";
import { hospitalLevle, hospitalType } from "../../config/HispitalFilter";
import { IfilterParam } from "../../type/CommonData";
import HospitalList from "./HospitalList";

interface States {
  conditions: Array<{ id: number; name: string }>;
  levels: Array<{ code: number; name: string }>;
  types: Array<{ code: number; name: string }>;
  data: {
    number: number;
    size: number;
    totalElements: number;
    content: [];
  };
}
interface Iprops {
  chlid: any;
}
/**
 * 按医院选择的页面
 */
class HospitalInto extends React.Component<Iprops, States> {
  public chlid: any;
  constructor(props: any) {
    super(props);
    this.state = {
      conditions: [],
      levels: [],
      types: [],
      data: {
        number: 5,
        size: 2,
        totalElements: 0,
        content: []
      }
    };
  }
  public loadData = (param: IfilterParam) => {
    this.chlid.props.getData(param);
  };
  public chlidrenLoad = (chlid: any) => {
    this.chlid = chlid;
  };
  public render() {
    return (
      <div>
        <SearchAndFilter
          arrayOne={hospitalLevle}
          arrayTwo={hospitalType}
          filterCallback={this.loadData}
          filterOne={"医院等级"}
          filterTwo={"医院类型"}
          Placeholder={"请输入医院名称"}
        />
        <HospitalList loadParent={this.chlidrenLoad} />
      </div>
    );
  }
}

export default HospitalInto;
